<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 求两个数的最大值
        function getMax(a, b) {
            return a > b ? a : b;
        }
        let num1 = +prompt('请输入第一个数字: ');
        let num2 = +prompt('请输入第二个数字: ');
        alert('最大值是: ' + getMax(num1, num2));

        // 求数组的最大值
        function getArrayMax(arr = []) {
            let max = arr[0];
            for (let i = 1; i < arr.length; i++) {
                max = getMax(max, arr[i]);
            }
            return max;
        }
        let numbers = [3, 5, 1, 8, 2];
        alert('数组最大值是: ' + getArrayMax(numbers));
    </script>
</body>
</html>